﻿#pragma once
// Inner Fire 游戏引擎库
// 材质类
//
// Copyright (c) 2023 by 尔西大帝. All rights reserved.
//
// 用于材质
//
// Author: 尔西大帝
// Email: 2670613871@qq.com
// Created: 2024-11-22

#include <dx_core/dx_core.h>

namespace ifire {

struct Material {
  // 材质的名称，用于查找
  std::string Name;

  // 本材质的常量缓冲区索引
  int MatCBIndex = -1;

  // 漫反射纹理在SRV堆中的索引
  int DiffuseSrvHeapIndex = -1;
  // 用于法线贴图
  int NormalSrvHeapIndex = -1;

  // 更新标记，用于资源帧
  int NumFramesDirty = FRAME_RESOURCE_COUNT;

  // 用于着色的材质常量缓冲区数据
  XMFLOAT4 DiffuseAlbedo = {1.0f, 1.0f, 1.0f, 1.0f};
  XMFLOAT3 FresnelR0 = {0.01f, 0.01f, 0.01f};
  float Roughness = 0.25f;
  XMFLOAT4X4 MatTransform = IDENTITY_4X4;
};

// 用于纹理索引
struct MaterialData {
  DirectX::XMFLOAT4 DiffuseAlbedo = {1.0f, 1.0f, 1.0f, 1.0f};
  DirectX::XMFLOAT3 FresnelR0 = {0.01f, 0.01f, 0.01f};
  float Roughness = 64.0f;

  // Used in texture mapping.
  DirectX::XMFLOAT4X4 MatTransform = IDENTITY_4X4;

  UINT DiffuseMapIndex = 0;
	UINT NormalMapIndex = 0;
  UINT MaterialPad1;
  UINT MaterialPad2;
};


} // namespace ifire